<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <h1>{{name}}</h1>
        <!-- 如果不传递参数，则默认是bt1($event) -->
        <button v-on:click='btn1'>点我(不传参)</button>
        <!-- $event必须要写上，否则会无法使用event -->
        <button @click='btn2($event,666)'>点我2(传参)</button>
    </div>
    <script>
        Vue.config.productionTip = false;
        let vm = new Vue({
            el:'#root',
            data:{name:'张三'},
            methods: {
                btn1(event){
                    alert("你干嘛~~~");
                    console.log(event);
                    console.log(this === vm);
                    // true
                },
                btn2(event,number){
                    alert("嘿嘿，小黑子，露出鸡脚了吧");
                    console.log(event,number);
                }
            },
        });
        console.log(vm._data.name);
    </script>
</body>
</html>